#include <DS1307RTC.h>
#include <Wire.h>
#include <IRremote.h>
#include <NewSoftSerial.h>
#include <goldelox.h>
#include <alice.h>
#include <Time.h>
#include <DB.h>
#include <LSM303compass.h>
#include <MatrixMath.h>

NewSoftSerial uSerial(2,3);
alice lcd;
LSM303compass c;
IRrecv irrecv(10);

void setup()  {

  Serial.begin(9600);
  setSyncProvider(RTC.get);   // the function to get the time from the RTC
    
    
  lcd.init(&uSerial);
  lcd.SDinit();

//lat,lon=40.433164,-3.672266
//Betelgeus 5 55 48 / 7 55 25
//Dubhe    11 03 43.7 /61 41 29
//Deneb    20 41 49 / 45 19 14
//Yed Prior 16,14,56 / -3,43,19
//Aldebaran 4,35,55.3 / 16,30,32.9
//Roseta    6,32,24 / 4,51,28
//Mizar     13,23,55.6 / 54,55,31.6
//M13       16,41,42  / 36,28,0  //FALLA
//andromeda 0,42,42 / 41,16,0
//M51       13,29,54 / 47,11,60
//M23       17,56,48 / -19,01,0

//  lcd.text(90,10,"Betel\n",lcd.getRGB(10,20,60)); 

  lcd.lon=-3.672266;
  lcd.lat=40.433164;


  lcd.penWire();
  lcd.opaqueText();
  lcd.ra=HHMMSStoRadians(17,56,48 )*15;
  lcd.dec=-M_PI/2;
//  lcd.dec=HHMMSStoRadians(-19,01,0);
  lcd.showScreen(4);
  c.enable(); 
 }

void loop(){ 
  c.readFilter(0.5);    
//  c.read();
  lcd.az=c.yaw;
  lcd.alt=c.pitch;
 // lcd.showHHMMSS(10,70,c.roll*180/M_PI,lcd.getRGB(60,0,0));
  lcd.showScreen(1);

  //lcd.showNearest(NGC);
}


